<template>
  <div class="job-list">
    <div
      class="job-item clearfix"
      v-for="j in jobList"
      :key="j.id"
      @click="jumpTo(j)"
    >
      <div class="job-pos">
        <div class="text">
          <span class="job-name">{{ j.cname }}</span>

        </div>
        <div class="wrap">
          <p>
            <i class="iconfont icon-map"></i><span>{{ j.province }} / {{ j.city }}</span>
          </p>
          <p>
            <i class="iconfont icon-hangye"></i
            ><span>{{ j.industry }}</span>
          </p>
          <p>
            <i class="iconfont icon-qiyeleixing"></i><span>{{ j.attr }}</span>
          </p>
          <p>
            <i class="iconfont icon-tuanduiguimo"></i><span>{{ j.size_data }}</span>
          </p>
        </div>
      </div>
      <el-button type="primary" plain v-permission="['personal']" @click="connect(j.id)" class="chat">联系企业</el-button>
      <div
        class="job-logo"
        :style="{background: 'url('+ j.logo +') center / cover no-repeat'}"
      >
      </div>
    </div>
  </div>
</template>

<script>

import {addChat1} from '@/api/job';
function stopBubbling(e) {
  e = window.event || e;
  if (e.stopPropagation) {
    e.stopPropagation();
  } else {
    e.cancelBubble = true;
  }
}
export default {
  props: ['list'],
  data () {
    return {
      jobList: [],
    }
  },
  created () {
  },
  mounted () {

  },
  watch: {
    list (val) {
      this.jobList = val;
    }
  },
  computed: {

  },
  methods: {
    jumpTo (obj) {
      const newsUrl = this.$router.resolve({
        path: '/company/detail',
        query: { id: obj.id }
      });
      window.open(newsUrl.href);
    },
    connect(id) {
      stopBubbling(event);
      addChat1({
        cid: id
      }).then(res => {
        if (res.code === 200) {
          this.$message.success('添加联系人成功，可进入交流平台进行交流');
        } else {
          this.$message.error(res.msg);
        }
      }).catch(err => {
        console.error(err)
        this.$message.error(err);
      })
    }
  },
}
</script>

<style lang="scss" scoped>

.job-list {
  margin: 20px auto;
  .job-item {
    height: 120px;
    width: 100%;
    border: 1px solid #ebebeb;
    background: #fff;
    margin-bottom: 10px;
    padding: 0 40px 0 40px;
    cursor: pointer;
    &:hover {
      background: #f6f7f8;
    }
    & > div {
      float: left;
    }
    .job-pos {
      width: 650px;
      font-size: 18px;
      margin-top: 30px;
      span {
        display: inline-block;
      }
      .job-name {
        color: #242924;
        margin-right: 40px;
      }
      .money {
        color: $base-color-important;
      }
      .wrap {
        margin-top: 10px;
        p {
          margin-right: 30px;
          color: #999;
          line-height: 20px;
          font-size: 14px;
          display: inline-block;
        }
        i {
          vertical-align: middle;
          color: #999;
          margin-right: 5px;
        }
        span {
          vertical-align: middle;
          color: #999;
        }
      }
    }
    .job-company {
      margin-top: 30px;
      width: 380px;
      .name {
        color: #24292f;
        margin-top: 10px;
      }
      .type {
        color: #999;
        font-size: 12px;
        margin-top: 5px;
      }
    }
    .chat {
      margin-top: 36px;
      overflow: hidden;

    }
    .job-logo {
      margin-top: 24px;
      height: 74px;
      width: 74px;
      overflow: hidden;
      float: right;
    }
  }
}
</style>
